package com.jsftoolkit.base.components;

import java.util.Collections;
import java.util.Set;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import com.jsftoolkit.base.ResourceConstants;
import com.jsftoolkit.base.ResourceInfo;
import com.jsftoolkit.base.ResourceInfo.Type;
import com.jsftoolkit.utils.Utils;

/**
 * This component renders nothing directly. By including it in the page,
 * {@link HtmlScripts} will pick up the resource it specifies and include it in
 * the page.
 * 
 * @author noah
 * 
 */
public class IncludeResource extends IncludeResourceBase {

	public Set<ResourceInfo> getResources(FacesContext context,
			UIComponent component) {
		return Collections.singleton(new ResourceInfo(getClientId(context),
				getResource(), Type.decode(getType()), getEncoding(),
				isFilter() ? getFilterBean() : null));
	}

	@Override
	public String getFilterBean() {
		// keep the filter bean from being empty
		return Utils.getValue(super.getFilterBean(),
				ResourceConstants.SKINNING_FILTER);
	}

}
